<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>JpetStore后台管理</title>
    <link rel="stylesheet" href="../../css/backstage.css" type="text/css"/>
    <script th:src = "@{/JS/jquery-3.2.1.js}"></script>
    <script th:src = "@{/JS/jquery-ui.js}"></script>
</head>
<body>
<div th:replace="/administrator/common/head.html"></div>
<div class="mid">

    <form action="/account/AdminUpdateAccount" method="post" id="editItemTable">
        <div>
            <a href="/account/AdminViewAccount">返回到用户信息(记得保存修改)</a>
        </div>
        <table>
            <tr>
                <td>用户名:&nbsp&nbsp&nbsp&nbsp</td>
                <td><input type="text" readonly="readonly" style="outline:none; width: 200px" th:value="${account.getUsername()}" name="username" id="username"></td>
            </tr>
            <tr>
                <td>密码:&nbsp&nbsp&nbsp&nbsp</td>
                <td><input type="password" readonly="readonly" style="outline:none; width: 200px" th:value="${account.getPassword()}" name="password"></td>
            </tr>
            <tr>
                <td>邮箱:&nbsp&nbsp&nbsp&nbsp</td>
                <td><input type="email" style="outline:none; width: 200px" th:value="${account.getEmail()}" name="email" required="required">
                </td>
            </tr>
            <tr>
                <td>姓:&nbsp&nbsp&nbsp&nbsp</td>
                <td><input type="text"  style="width: 200px" th:value="${account.getFirstName()}" name="firstName" required="required">
                </td>
            </tr>
            <tr>
                <td>名:&nbsp&nbsp&nbsp&nbsp</td>
                <td><input type="text"  style="width: 200px" th:value="${account.getLastName()}" name="lastName" required="required">
                </td>
            </tr>
            <tr>
                <td>住址1:&nbsp&nbsp&nbsp&nbsp</td>
                <td><input type="text"  style="width: 200px" th:value="${account.getAddress1()}" name="address1" required="required">
                </td>
            </tr>
            <tr>
                <td>住址2:&nbsp&nbsp&nbsp&nbsp</td>
                <td><input type="text"  style="width: 200px" th:value="${account.getAddress2()}" name="address2">
                </td>
            </tr>
            <tr>
                <td>国家:&nbsp&nbsp&nbsp&nbsp</td>
                <td><input type="text"  style="width: 200px" th:value="${account.getCountry()}" name="country">
                </td>
            </tr>
            <tr>
                <td>省份:&nbsp&nbsp&nbsp&nbsp</td>
                <td><input type="text"  style="width: 200px" th:value="${account.getCity()}" name="city">
                </td>
            </tr>
            <tr>
                <td>城市:&nbsp&nbsp&nbsp&nbsp</td>
                <td><input type="text"  style="width: 200px" th:value="${account.getState()}" name="state">
                </td>
            </tr>
            <tr>
                <td>邮编:&nbsp&nbsp&nbsp&nbsp</td>
                <td><input type="text"  style="width: 200px" th:value="${account.getZip()}" name="zip">
                </td>
            </tr>
            <tr>
                <td>电话:&nbsp&nbsp&nbsp&nbsp</td>
                <td><input type="phone"  style="width: 200px" th:value="${account.getPhone()}" name="phone">
                </td>
            </tr>
        </table>
        <td>
            <input type="submit" style="font-size: 16px;" value="保存"></td>
        <td><a th:href="@{'/account/deleteAccount?username='+${account.getUsername()}}">删除该用户</a>
        </td>
        <td><button id="reset_password" type="button">重置密码</button></td>
        <script>
            var username1=document.getElementById("username");
            var reset_password=document.getElementById("reset_password");
            reset_password.onclick=reset;
            var xhr;

            function reset(){
                xhr = new XMLHttpRequest();
                xhr.onreadystatechange = processReset;
                xhr.open("GET","/account/resetPassword?username="+username1.value);
                xhr.send(null);
            }

            function processReset(){
                if (xhr.readyState == 4) {
                    if (xhr.status == 200) {
                        alert("密码已经重置为123456789");
                    }
                }
            }
        </script>
    </form>
</div>
<div th:replace="/administrator/common/foot.html"></div>
</body>
</html>